<template>
  <div>
    <searchBar placeHolder="请输入车主姓名"
               @handleSearch='init' />
    <el-table :data="tableData">
      <el-table-column align="center"
                       label="车主姓名"
                       prop="name">
      </el-table-column>
      <el-table-column align="center"
                       label="购卡金额"
                       prop="card_price">
      </el-table-column>
      <el-table-column align="center"
                       label="捐赠公益金"
                       prop="money">
      </el-table-column>
      <el-table-column align="center"
                       label="时间"
                       prop="create_time">
      </el-table-column>
    </el-table>
    <div style="margin:10px 10px;text-align:right">
      {{Totalsum}}
    </div>
    <v-pagination :total='total'
                  :page.sync='page' />
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      total: 0,
      page: 1,
      Totalsum: 0
    }
  },
  methods: {
    async init (data) {
      console.log(data)
      const { search, start_time, end_time } = data || ''
      try {
        const res = await this.api.interestList(Object.assign({}, { key: search, start_time: start_time, end_time: end_time, page: this.page }))
        this.tableData = res.data.list || []
        this.total = res.data.rows || 0
        this.Totalsum = res.data.total || 0
      } catch (err) {
        this.$message('接口出错,请联系管理员')
      }
    }
  },
  mounted () {
    this.init()
  }
}
</script>

<style>
</style>
